package A2;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;

public class URL1 {
    public static void main(String[] args) {
        URL get;
        try {
            get = new URL("https://www.baidu.com/");
        } catch (MalformedURLException e) {
            return;
        }
        try (
                InputStream is = get.openStream();
                InputStreamReader in = new InputStreamReader(is);
                BufferedReader br = new BufferedReader(in);
                ){
            StringBuilder str = new StringBuilder();
            String lin = br.readLine();
            while (lin != null){
                str.append(lin);
                str.append("\n");
                lin = br.readLine();
            }
            System.out.println(str);

        }catch (Throwable e ){
            e.printStackTrace();
        }

    }
}
